package XieCheng;

import java.util.Arrays;

/**
 * Description：
 * Author: zhangc
 * Date：2017/9/21 19:28
 */
public class Main {


    public static void main(String[] args) {

        int[] arr = {5, 3, 4, -1, 1, 1, 1, 2, 6};
        System.out.println(findMinMis(arr));

    }

    static int findMinMis(int[] A) {

        Arrays.sort(A);
        for (int i = 0; i < A.length - 1; i++) {
            if (A[ i ] <= 0 && A[ i + 1 ] > 1)
                return 1;
        }
        int i = 0;
        for (; i < A.length - 1; i++) {
            if (A[ i ] > 0 && A[ i ] + 1 < A[ i + 1 ])
                return A[ i ] + 1;
        }
        return A[ i ] + 1;
    }

}
